package com.test2015.Swing.jspinner;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.text.DateFormatSymbols;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;

import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerModel;

import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;

import com.test2015.Swing.ext.ipfield.IPV4AddressField;
import com.test2015.Swing.ext.ipfield.JHistoryTextField;
import com.test2015.Swing.ext.ipfield.MacField;

public class JSpinnerTest extends JFrame{
	
	IPV4AddressField ipfield = new IPV4AddressField("127.0.0.1");
	MacField mf = new MacField("FF:FF:FF:FF:FF:FF");
	JHistoryTextField historyField = new JHistoryTextField();
	
	public JSpinnerTest(){
		JPanel pane = getMainPanel();
		
		this.getContentPane().add(pane,BorderLayout.NORTH);
//		this.getContentPane().add(ipfield,BorderLayout.SOUTH);
		this.getContentPane().add(mf);
		
		this.pack();
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	private JPanel getMainPanel() {
		JPanel pane = new JPanel();	

		String[] months = new DateFormatSymbols().getMonths();
		SpinnerModel model = new SpinnerListModel(months);
		JSpinner spinner = new JSpinner(model);
		
		JFormattedTextField intField = new JFormattedTextField(NumberFormat.getIntegerInstance());
		intField.setPreferredSize(new Dimension(100,25));
	
		pane.add(ipfield);
		pane.add(intField);
		pane.add(spinner);
		
		historyField.setPreferredSize(new Dimension(150,25));
		String hiss = "armageddon,cars,cartoon,casanova,casino,castle,castlevania,cat,category,caterpillar,click,dog,magpie,hare,rabbit";
		historyField.setHistory(Arrays.asList(hiss.split(",")));
		pane.add(historyField);
		
		return pane;
	}

	public static void main(String[] args) throws Exception {
		BeautyEyeLNFHelper.launchBeautyEyeLNF();
		new JSpinnerTest();
	}
}	
